import { $wuxButton } from '../../components/wux'

Page({
	data: {
		types: ['topLeft', 'topRight', 'bottomLeft', 'bottomRight'], 
		index: 3, 
		opened: !1, 
	},
	onLoad() {
		this.initButton()
	},
	initButton(position = 'bottomRight') {
		this.setData({
			opened: !1, 
		})

		this.button = $wuxButton.init('br', {
			position: position, 
			buttons: [
				{
					label: 'View on Github', 
					icon: "", 
				},
				{
					label: 'View on About', 
					icon: "", 
				},
				{
					label: 'View on Demo', 
					icon: "", 
				}
			],
			buttonClicked(index, item) {
				index === 0 && wx.showModal({
					title: 'Thank you for your support!', 
					showCancel: !1, 
				})

				index === 1 && wx.switchTab({
					url: '/pages/about/index'
				})

				index === 2 && wx.switchTab({
					url: '/pages/index/index'
				})

				return true
			},
			callback(vm, opened) {
				vm.setData({
					opened, 
				})
			},
		})
	},
	switchChange(e) {
		e.detail.value ? this.button.open() : this.button.close()
	},
	pickerChange(e) {
		const index = e.detail.value
		const position = this.data.types[index]
		this.initButton(position)
	},
})